;##################################
;命令：
;nasm -f elf64 day4_0vector_0add_1ymm_1float.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Value in arr[0] is 1.234500.
;Value in arr[1] is 2.345600.
;Value in arr[2] is 3.456700.
;Value in arr[3] is 4.567800.
;Value in arr[4] is 5.678900.
;Value in arr[5] is 6.790000.
;Value in arr[6] is 7.900100.
;Value in arr[7] is 9.001200.
;##################################
extern printf

section .data
	msg: db `Value in arr[%d] is %f.\n`, 0
	arr0: dd 0.1234, 1.2345, 2.3456, 3.4567, 4.5678, 5.6789, 6.7890, 7.8901
	arr1: dd 1.1111, 1.1111, 1.1111, 1.1111, 1.1111, 1.1111, 1.1111, 1.1111
	x: dq 0                                         ;

section .text
	global main

main:
	push rbp
	mov rbp, rsp

;####################################
	vmovups ymm0, [arr0]
	vmovups ymm1, [arr1]
	vaddps ymm0, ymm0, ymm1
	vmovups [arr0], ymm0
;####################################

;######################################################
	;打印
	mov ebx, 0
	jmp compare

execute:
	mov rdi, msg
	movsxd rsi, ebx
	cvtss2sd xmm0, dword [arr0 + 4 * ebx]
	movq rdx, xmm0
	call printf

	inc ebx

compare:
	cmp ebx, 8
	jl execute
;######################################################

	mov eax, 0
	leave
	ret
